package com.game.common;

import com.game.message.Msg;
import com.game.message.connetion.ConnectionManager;
import com.game.message.jpb.JPbUtil;
import com.game.messagebean.common.PromptResp;
import io.netty.channel.ChannelHandlerContext;

/**
 * 发送消息
 *
 * @author Tony
 * @createAt Feb 17, 2015
 */
public class MsgSendHelper {
	public static void sendMsg(int userId, Msg msg) {
		ConnectionManager.getInstance().writeMessage(userId, msg);
	}

	public static void sendMsg(ChannelHandlerContext ctx, Msg message) {
		ConnectionManager.getInstance().writeMessage(ctx, message);
	}

	/**
	 * 发送提示消息
	 * @param userId
	 * @param promptResp
	 */
	public static void sendPrompt(int userId,PromptResp promptResp) {
		Msg msg = JPbUtil.getMsg(PromptResp.class, promptResp);
		msg.setUserId(userId);
		sendMsg(userId,msg);
	}
}
